home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / gcc / ixemlsrc.lha / ixemul / ixnet / page.h < prev    next >
C/C++ Source or Header  |  1996-03-13  |  4KB  |  107 lines

  1. #ifndef _PAGE_H_
  2. #define _PAGE_H_
  3.  
  4. /*-
  5.  * Copyright (c) 1990 The Regents of the University of California.
  6.  * All rights reserved.
  7.  *
  8.  * This code is derived from software contributed to Berkeley by
  9.  * Margo Seltzer.
  10.  *
  11.  * Redistribution and use in source and binary forms, with or without
  12.  * modification, are permitted provided that the following conditions
  13.  * are met:
  14.  * 1. Redistributions of source code must retain the above copyright
  15.  *    notice, this list of conditions and the following disclaimer.
  16.  * 2. Redistributions in binary form must reproduce the above copyright
  17.  *    notice, this list of conditions and the following disclaimer in the
  18.  *    documentation and/or other materials provided with the distribution.
  19.  * 3. All advertising materials mentioning features or use of this software
  20.  *    must display the following acknowledgement:
  21.  *    This product includes software developed by the University of
  22.  *    California, Berkeley and its contributors.
  23.  * 4. Neither the name of the University nor the names of its contributors
  24.  *    may be used to endorse or promote products derived from this software
  25.  *    without specific prior written permission.
  26.  *
  27.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  28.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  31.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  33.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  34.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  35.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  36.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  37.  * SUCH DAMAGE.
  38.  *
  39.  *    @(#)page.h    5.1 (Berkeley) 2/12/91
  40.  */
  41.  
  42. #include "hash.h"
  43. #include <db.h>
  44. /*
  45.     Definitions for hashing page file format.
  46. */
  47. extern    HTAB    *hashp;
  48. /*
  49.  * routines dealing with a data page
  50.  *
  51.  * page format:
  52.  *    +------------------------------+
  53.  * p    | n | keyoff | datoff | keyoff |
  54.  *     +------------+--------+--------+
  55.  *    | datoff | free  |  ptr  | --> |
  56.  *    +--------+---------------------+
  57.  *    |     F R E E A R E A       |
  58.  *    +--------------+---------------+
  59.  *    |  <---- - - - | data          |
  60.  *    +--------+-----+----+----------+
  61.  *    |  key   | data     | key      |
  62.  *    +--------+----------+----------+
  63.  *
  64.  * Pointer to the free space is always:  p[p[0] + 2]
  65.  * Amount of free space on the page is:  p[p[0] + 1]
  66.  */
  67.  
  68. /*
  69.     How many bytes required for this pair?
  70.     2 shorts in the table at the top of the page +
  71.     room for the key and room for the data
  72.  
  73.     We prohibit entering a pair on a page unless there is also
  74.     room to append an overflow page. The reason for this it that
  75.     you can get in a situation where a single key/data pair fits
  76.     on a page, but you can't append an overflow page and later
  77.     you'd have to split the key/data and handle like a big pair.
  78.     You might as well do this up front.
  79.  
  80. */
  81. #define    PAIRSIZE(K,D)    (2*sizeof(u_short) + K->size + D->size)
  82. #define BIGOVERHEAD    (4*sizeof(u_short))
  83. #define KEYSIZE(K)    (4*sizeof(u_short) + K->size);
  84. #define OVFLSIZE    (2*sizeof(u_short))
  85. #define FREESPACE(P)    (P[P[0]+1])
  86. #define    OFFSET(P)    (P[P[0]+2])
  87. #define PAIRFITS(P,K,D)    ((P[1] >= REAL_KEY) && \
  88.              (PAIRSIZE(K,D) + OVFLSIZE) <= FREESPACE(P))
  89. #define PAGE_META(N)    ((N+3) * sizeof(u_short))
  90.  
  91. typedef struct {
  92.     BUFHEAD    *newp;
  93.     BUFHEAD    *oldp;
  94.     BUFHEAD    *nextp;
  95.     u_short    next_addr;
  96. } SPLIT_RETURN;
  97.  
  98. int __delpair(BUFHEAD *, int);
  99. int __split_page(u_int, u_int);
  100. int __addel(BUFHEAD *, DBT *, DBT *);
  101. BUFHEAD *__add_ovflpage(BUFHEAD *);
  102. int __get_page(char *, u_int, int, int, int);
  103. int __put_page(char *, u_int, int, int);
  104. u_long *__init_bitmap(u_short, int, int);
  105. void __free_ovflpage(BUFHEAD *);
  106. #endif
  107.